param location string
param applicationGatewayName string
param aksClusterUserDefinedManagedIdentityName string
param aadPodIdentityUserDefinedManagedIdentityName string

var applicationGatewayUserDefinedManagedIdentityName = '${applicationGatewayName}ManagedIdentity'

resource applicationGatewayUserDefinedManagedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
  name: applicationGatewayUserDefinedManagedIdentityName
  location: location
}

resource aksClusterUserDefinedManagedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-07-31-preview' = {
  name: aksClusterUserDefinedManagedIdentityName
  location: location
}

resource aadPodIdentityUserDefinedManagedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-07-31-preview' = {
  name: aadPodIdentityUserDefinedManagedIdentityName
  location: location
}

output applicationGatewayUserDefinedManagedIdentityId string = applicationGatewayUserDefinedManagedIdentity.id
output aksClusterUserDefinedManagedIdentityId string = aksClusterUserDefinedManagedIdentity.id
output aadPodIdentityUserDefinedManagedIdentityId string = aadPodIdentityUserDefinedManagedIdentity.id

output applicationGatewayUserDefinedManagedIdentityTenantId string = applicationGatewayUserDefinedManagedIdentity.properties.tenantId
output aksClusterUserDefinedManagedIdentityTenantId string = aksClusterUserDefinedManagedIdentity.properties.tenantId
output aadPodIdentityUserDefinedManagedIdentityTenantId string = aadPodIdentityUserDefinedManagedIdentity.properties.tenantId

output applicationGatewayUserDefinedManagedIdentityPrincipalId string = applicationGatewayUserDefinedManagedIdentity.properties.principalId
output aksClusterUserDefinedManagedIdentityPrincipalId string = aksClusterUserDefinedManagedIdentity.properties.principalId
output aadPodIdentityUserDefinedManagedIdentityPrincipalId string = aadPodIdentityUserDefinedManagedIdentity.properties.principalId
